<html>
  <head></head>
</html>
<body>
  <h1 style="text-align: center">Css学习</h1>
  <hr style="border: 1px solid red" />

  <div class="tooltip">
    鼠标移动到这
    <span class="tooltiptext">提示文本</span>
  </div>
</body>
<style>
  .tooltip {
    position: relative;
    display: inline-block;
    /* div 元素下面的线 */
    border-bottom: 1px dotted black;
  }

  .tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: black;
    color: #fff;
    text-align: center;
    padding: 5px 0;
    border-radius: 6px;

    /* 定位 */
    position: absolute;
    z-index: 1;
  }

  .tooltip:hover .tooltiptext {
    visibility: visible;
  }
</style>
